/*
 *
 * Power of
 *
 */
unsigned int atoh_map[255];
unsigned char htoa_map[255];
unsigned char xor_helper[112];


long int pow(long int num, int power) {
	if (power == 0) {
		return 1L;
	}

	if (power == 1) {
		return num;
	}
	long int ret = 1;
	while (power != 0) {
		ret = ret * num;
		power --;
	}
	return ret;
}

void math_init(void) {

        xor_helper[58] = 0;
        xor_helper[59] = 1;
        xor_helper[56] = 2;
        xor_helper[57] = 3;
        xor_helper[62] = 4;
        xor_helper[63] = 5;
        xor_helper[60] = 6;
        xor_helper[61] = 7;
        xor_helper[50] = 8;
        xor_helper[51] = 9;
        xor_helper[107] = 10;
        xor_helper[104] = 11;
        xor_helper[105] = 12;
        xor_helper[110] = 13;
        xor_helper[111] = 14;
        xor_helper[108] = 15;


        int i, j;

	/*
         *
         * Fill in the atoh_map
         *
         */
        for (i = 97, j = 10; i <= 102; i ++, j ++) {
                atoh_map[i] = j;
        }

        for (i = 65, j = 10; i <= 70; i ++, j ++ ) {
                atoh_map[i] = j;
        }

        for (i = 48, j = 0; i <= 57; i ++, j ++) {
                atoh_map[i] = j;
        }

	for (i = 0; i < 10; i ++) {
		htoa_map[i] = (unsigned char) (48 + i);
	}
	for (i = 10; i <= 15; i ++) {
		htoa_map[i] = (unsigned char) (87 + i);
	}
}
